package bracketmatch

import "github.com/molio/practice/ds/stack"

// 判断字符中括号是否匹配

func IsBracketMatch(bracketStr string) bool {
	bsLen := len(bracketStr)
	linkStack := stack.NewLinkStack()
	for i := 0; i < bsLen; i++ {
		if bracketStr[i] == '(' {
			linkStack.PushStack(bracketStr[i])
		} else if bracketStr[i] == ')' {
			linkStack.PopStack()
		}
	}
	return linkStack.IsEmpty()
}
